<template>
<div class="user">
    <!--搜索表单-->
    <div class="common-seach-wrap">
      <el-form
        size="small"
        :inline="true"
        :model="formInline"
        class="demo-form-inline"
      >
        <el-form-item :label="$t('user.nickname_or_id')">
          <el-input
            v-model="formInline.search"
            :placeholder="$t('user.input_nickname_or_id')"
          ></el-input>
        </el-form-item>
        <el-form-item :label="$t('user.register_time')">
          <div class="block">
            <span class="demonstration"></span>
            <el-date-picker
              v-model="formInline.value"
              type="daterange"
              :range-separator="$t('user.to')"
              :start-placeholder="$t('user.date_start')"
              :end-placeholder="$t('user.date_end')"
            >
            </el-date-picker>
          </div>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="Search" @click="onSubmit"
            >{{$t('user.search')}}</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <!--内容-->
    <div class="product-content">
      <div class="table-wrap">
        <el-table
          size="small"
          :data="tableData"
          border
          style="width: 100%"
          v-loading="loading"
        >
          <el-table-column prop="userId" :label="$t('user.user_id_label')"></el-table-column>
          <el-table-column prop="orderNo" :label="$t('user.order_number')"></el-table-column>
          <el-table-column prop="nickName" :label="$t('user.wechat_nickname')"></el-table-column>
          <el-table-column prop="nickName" :label="$t('user.wechat_avatar')" width="70">
            <template #default="scope">
              <img :src="scope.row.avatarUrl" width="30" height="30" />
            </template>
          </el-table-column>
          <el-table-column
            prop="snapshot.plan_name"
            :label="$t('user.recharge_packages')"
          ></el-table-column>
          <el-table-column prop="payPrice" :label="$t('user.paid_amount')"></el-table-column>
          <el-table-column prop="realMoney" :label="$t('user.received_amount')"></el-table-column>
          <el-table-column :label="$t('user.recharge_method')">
            <template #default="scope">
              <span v-if="scope.row.type && scope.row.type == 10"
                >{{$t('user.custom_amount')}}</span
              >
              <span v-if="scope.row.type && scope.row.type == 20" class="green"
                >{{$t('user.package_recharge')}}</span
              >
            </template>
          </el-table-column>
          <el-table-column :label="$t('user.payment_status')">
            <template #default="scope">
              <span v-if="scope.row.payStatus && scope.row.payStatus == 10"
                >{{$t('user.pending_payment')}}</span
              >
              <span
                v-if="scope.row.payStatus && scope.row.payStatus == 20"
                class="green"
                >{{$t('user.paid')}}</span
              >
            </template>
          </el-table-column>
          <el-table-column prop="createTime" :label="$t('user.recharge_time')"></el-table-column>
        </el-table>
      </div>

      <!--分页-->
      <div class="pagination">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          background
          :current-page="curPage"
          :page-size="pageSize"
          layout="total, prev, pager, next, jumper"
          :total="totalDataNumber"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import PlanApi from "@/api/balance.js";
export default {
  components: {},
  data() {
    return {
      /*是否加载完成*/
      loading: true,
      /*列表数据*/
      tableData: [],
      /*一页多少条*/
      pageSize: 10,
      /*一共多少条数据*/
      totalDataNumber: 0,
      /*当前是第几页*/
      curPage: 1,
      /*横向表单数据模型*/
      formInline: {
        search: "",
        value: []
      }
    };
  },
  created() {
    /*获取列表*/
    this.getTableList();
  },
  methods: {
    /*选择第几页*/
    handleCurrentChange(val) {
      let self = this;
      self.curPage = val;
      self.loading = true;
      self.getTableList();
    },
    /*每页多少条*/
    handleSizeChange(val) {
      this.curPage = 1;
      this.pageSize = val;
      this.getTableList();
    },
    /*获取列表*/
    getTableList() {
      let self = this;
      let Params = self.formInline;
      Params.page = self.curPage;
      Params.list_rows = self.pageSize;
      PlanApi.log(Params, true).then(res => {
        self.loading = false;
        self.tableData = res.data.records;
        self.totalDataNumber = res.data.total;
      }).catch(error => {});
    },
    /*搜索查询*/
    onSubmit() {
      let self = this;
      self.loading = true;
      self.getTableList();
    }
  }
};
</script>

